package GUI;

import Control.Character;
import processing.core.PImage;
import processing.core.PImage;


public class CloseButton extends Component {
	Character c;
	public boolean clicked;
	public boolean pressed;

	////////////////////////////////////////////////////////////////////////////////////////////////////
	public CloseButton(Character ci)
	{
		super();
		width=12;
		height=12;
		c=ci;
	}
	public void draw()
	{
		Utils.globalProcessing.textFont(Utils.plotFont, 19);
		Utils.globalProcessing.stroke(128);
		Utils.globalProcessing.line(x, y, x+width, y+height);
		Utils.globalProcessing.line(x+width, y, x, y+height);

		int cx = x;
		int cy = y;

		Utils.globalProcessing.textAlign(Utils.globalProcessing.LEFT);

		if(mouseOver()) 
		{
			super.draw();
			if(Utils.globalProcessing.mousePressed)
			{
				//gu.drawVGradient(x, y + height, width, -height, color(150, 150, 180), 80, color(150, 150, 180), 255, 0.8);    
				Utils.gu.drawBox(x, y, width, height, 0, Utils.globalProcessing.color(150, 150, 200), 255);
				Utils.gu.drawBox(x, y, width, height, 1, Utils.globalProcessing.color(150, 150, 200), 150);
                pressed = true;

				cx += 2;
				cy += 2;
			}
			else if(pressed)
            {
                pressed = false;
                clicked = true;
                mouseCliked();
            }
        }
        else
        {
            pressed = false;
        }

	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	PImage icon;
	String label;

	public void mouseCliked() {
		Utils.ccip.removeCharacterSelected(c);
	}
}
